import service from '@/utils/request'

//创建人select查询下拉
export const getUserList=(data)=> {
  return new Promise((resolve, reject) => {
    service.post('/boss/boss-user/boss-user-list', data)
      .then(res => {
        let list = res.data?.data||[]
        resolve(list.map((item)=>{
            return  {
                label:item.nick,
                value:item.id
            }
        }))
      })
  })
}


//耕种方式查询下拉
export const getSelectList=(data)=> {
    return new Promise((resolve, reject) => {
      service.post('/boss/common/lov/page', data)
        .then(res => {
          let list = res.data?.data||[]
          resolve(list.map((item)=>{
              return  {
                  label:item.meaning,
                  value:item.valueCode
              }
          }))
        })
    })
  }


//负责人select查询下拉
export const getTeamList=(data)=> {
  return new Promise((resolve, reject) => {
    service.post('/boss/team/team-list', data)
      .then(res => {
        let list = res.data?.data||[]
        resolve(list.map((item)=>{
            return  {
                label:item.realName,
                value:item.userId
            }
        }))
      })
  })
}

//角色select查询下拉
export const getTeamRoleList=(data)=> {
  return new Promise((resolve, reject) => {
    service.get('/boss/team/team-role-list', data)
      .then(res => {
        let list = res.data?.data||[]
        resolve(list.map((item)=>{
            return  {
                label:item.roleName,
                value:item.teamRoleId
            }
        }))
      })
  })
}
//公司所属select查询下拉
export const getCompanyList=(data)=> {
  return new Promise((resolve, reject) => {
    service.post('/boss/role/role-company-list', data)
      .then(res => {
        let list = res.data?.data||[]
        resolve(list.map((item)=>{
            return  {
                label:item.roleName,
                value:item.id
            }
        }))
      })
  })
}


//计划方案下拉
export const getPlanSelectList=(data)=> {
  return new Promise((resolve, reject) => {
    service.post('/boss/tanc_plantint_plan/list', data)
      .then(res => {
        let list = res.data?.data||[]
        resolve(list.map((item)=>{
            return  {
                label:item.name,
                value:item.plantingPlanId
            }
        }))
      })
  })
}

